package com.custom.base.ui.activity

import android.content.Context
import android.os.Bundle
import com.alibaba.android.arouter.launcher.ARouter
import com.custom.base.presenter.BasePresenter
import com.custom.base.presenter.view.BaseView


abstract class BaseMvpActivity<T : BasePresenter<*>> : BaseActivity(), BaseView {

    //Presenter泛型，Dagger注入
    lateinit var mPresenter: T

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ARouter.getInstance().inject(this) //ARouter注册
        mPresenter = initComponent()
        initData()
    }

    /**
     * 注册组件
     */
    abstract fun initComponent(): T

    /**
     * 初始化数据
     */
    abstract fun initData()

    override fun showLoading() {}
    override fun onError(throwable: Throwable) {}
}
